package com.springboot.framework.service.impl;

import com.springboot.framework.dao.entity.User;
import com.springboot.framework.dao.mapper.UserMapper;
import com.springboot.framework.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public User get(String wechatOpenid) {
        User user = new User();
        user.setWechatOpenid(wechatOpenid);
        return userMapper.selectOne(user);
    }

    @Override
    public int insert(User user) {
        if (userMapper.selectOne(user) != null) {
            return 0;
        }
        return userMapper.insertSelective(user);
    }
}
